package com.fangda.network.tcp.server;

import com.fangda.network.NetworkConfig;
import com.fangda.network.NetworkProvider;
import io.vertx.core.Vertx;
import io.vertx.core.net.NetServer;
import io.vertx.core.net.NetServerOptions;

public class TcpServerProvider implements NetworkProvider<TcpServerNetwork> {

	public TcpServerNetwork createNetwork(Vertx vertx, String id, NetworkConfig networkConfig) {
        TcpServerNetwork network = new TcpServerNetwork(id, networkConfig);
        NetServerOptions config = (NetServerOptions)networkConfig.getConfig().getOrDefault("options", new NetServerOptions());
        NetServer server = vertx.createNetServer(config);

        network.setServer(server);
        return network;
    }

}
